package com.toycloud.config.controller;

import cn.dev33.satoken.sso.SaSsoUtil;
import com.toycloud.common.core.domain.R;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * token 控制
 *
 * @author ruoyi
 */
@RestController
public class TokenController {
    @Value("${spring.profiles.active}")
    private String activeProfile;

    @GetMapping("/login")
    public R<String> login() {
        // 构造第三方登录 URL
        String thirdPartyLoginUrl = "";
        if ("prod".equals(activeProfile)) {
            thirdPartyLoginUrl = SaSsoUtil.buildServerAuthUrl("https://tcfb.toycloud.com", "");
        } else {
            thirdPartyLoginUrl = SaSsoUtil.buildServerAuthUrl("http://10.10.223.186:8098", "");
        }
        // 返回第三方登录 URL 给前端
        return R.ok(thirdPartyLoginUrl);
    }

}
